﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Web;
using System.Web.Mvc;
using Lvzhi.Entities;
using Newtonsoft.Json;

namespace Lvzhi.AdminCenter.Controllers
{
    public class TestController : BaseController
    {
        // GET: Test
        public ActionResult Edit2()
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://test.hxlife.com/");
                var requestJson = JsonConvert.SerializeObject(
                    new
                    {
                        third_serial_no = "20180226142325259",
                        user_name = "cecece1",
                        policy_no = "2600000392700468",
                        cancel_date = "2018-02-28 14:52:14",
                        prem = ""
                    });



                HttpContent httpContent = new StringContent(requestJson);

                httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");



                var result = client.PostAsync("services/rest/policy/cancel", httpContent).Result.Content.ReadAsStringAsync().Result;

                return Content(result);
            }
        }



        // GET: Test
        public ActionResult Edit()
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://test.hxlife.com/");
                var requestJson = JsonConvert.SerializeObject(
                    new
                    {
                        third_serial_no = "1212121123333",
                        user_name = "cecece1",
                        agent_code = "12345",
                        //agent_com = "1234567890",
                        //manage_com = "86110161",
                        channel_detail = "21",
                        pol_apply_date = "2018-02-04 17:03:01",
                        cvali_date = "2018-02-04 17:03:17",
                        plan = new
                        {
                            plan_code = "DMCTEST01",
                            mult = "1"
                        },
                        appnt = new
                        {
                            appnt_name = "测试投保人233",
                            appnt_sex = "M",
                            appnt_birthday = "1980-01-01",
                            appnt_id_type = "0",
                            appnt_id_no = "110101198001010010"
                        },
                        insured = new
                        {
                            relation_to_appnt = "31",
                            insured_name = "测试被保人233",
                            insured_sex = "M",
                            insured_birthday = "1980-01-01",
                            insured_id_type = "0",
                            insured_id_no = "110101198001010053",
                            occupation_code = "1020202"
                        },


                    });



                HttpContent httpContent = new StringContent(requestJson);

                httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");



                var result = client.PostAsync("services/rest/policy/new", httpContent).Result.Content.ReadAsStringAsync().Result;

                return Content(result);
            }
            return View(new Core_Goods());
        }


    }
}